<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title></title>
</head>


<body>
    <script src="js/mui.min.js"></script>
    <script src="js/vue.min.js"></script>
    <script src="js/url.js"></script>
    <script src="js/ajax.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript">

        function GetQueryString(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return unescape(r[2]);
            return null;
        }

        var code = GetQueryString("code");
        var state = GetQueryString("state");
        var str = state.split("@");


        console.log(code);
        console.log(state);
        console.log(str);


        var topicId = str[0];  // 文章 id
        var flag = str[1];   // 1 科普  2 下载

        if (flag == 1) {//科普
            sessionStorage.aiMinTopicId = topicId
            window.location.replace("topicDetail.html")
        }
        if (flag == 2) {// 下载
            window.location.replace("aiMinIndex.html")
        }


        var app = new Vue({
            el: '#app',
            methods: {
                getData: function () {
                    var _this = this;
                    console.log(code);

                    return
                    ajax({
                        url: newUrl + "user/toShare",
                        type: 'post',
                        data: {
                            code: code,
                        },
                        dataType: 'json',
                        timeout: 10000,
                        contentType: "application/json",
                        success: function (data) {
                            console.log();
                            var data = JSON.parse(data)
                            if (data.flag) {

                                var results = data.data;
                                if (results.flag == "error") {
                                    alert(results.msg);
                                    return;
                                } else {
                                    if (flag == 1) {//科普
                                        sessionStorage.aiMinTopicId = topicId
                                        window.location.replace("topicDetail.html")
                                    }
                                    if (flag == 2) {// 下载
                                        window.location.replace("aiMinIndex.html")
                                    }
                                }
                            }
                        },
                    })
                },
            },
            created: function () {
                this.getData();
            }
        })
    </script>
</body>

</html>